const mongoose = require('mongoose')
const fs = require('fs')
const path = require('path')

// 记录日志 日志按天记录
// const path = require('path')
// const fs = require('fs')
// const os = require('os')
// const dt = require('../../utils/date')
// const moment = require('moment')
// const app = require( '../../middleware/log')





// 数据库配置文件
const { host, opts } = require('../../config/db')

// 连接 mongodb 服务器
mongoose.connect(host, opts, (err => {
    if (err) {
        console.log("链接失败");
    } else {
        console.log("链接成功")
        let logpath = path.join(path.dirname(path.dirname(__dirname)), 'logs', 'conn.log')
        // let logpath = path.join(path.dirname(path.dirname(__dirname)), 'logs', `${dt.formDataTime()}.log`)

        fs.appendFileSync(logpath, 'aaaa')
    }
}))

// 这里需要连接成功的日志记录



module.exports = mongoose



